package com.qiang.test02;

import java.io.*;
import java.util.Arrays;
import java.util.TreeSet;

public class Demo07 {
    public static void main(String[] args) throws IOException {
        //使用字符缓冲流读取文件中的数据，排序后再次写到本地文件

        BufferedWriter bw = new BufferedWriter(new FileWriter("yy.txt"));
        String s = "12,34,21,56,33,1,99";
        bw.write(s);
        bw.close();

        BufferedReader br = new BufferedReader(new FileReader("yy.txt"));
        String s1 = br.readLine();
        //System.out.println(s1);
        //System.out.println(s1.length());
        String[] ss = s1.split(",");
        /*int[] arr = new int[ss.length];
        for (int i = 0; i < ss.length; i++) {
            arr[i] = Integer.parseInt(ss[i]);
        }*/
        /*for (int i : arr) {
            System.out.println(i);
        }*/

        /*Arrays.sort(arr);
        for (int i : arr) {
            System.out.println(i);
        }*/

        TreeSet<Integer> it = new TreeSet<>();
        for (int i = 0; i < ss.length; i++) {
            it.add(Integer.parseInt(ss[i]));
        }
        System.out.println(it);

    }
}
